import { useState } from 'react';

export default function TrafficLight() {
    const [walk,setWalk]=useState(true)
    const change=()=>{
        // alert(walk?'Stop is next':'Walk is next')
        setWalk(!walk)
        alert(walk?'Stop is next':'Walk is next')

    }
  return<>
    <button onClick={change}>
        change to {walk?'stop':'walk'}
    </button>
    <hr/>
    <h1 style={{color:walk?'darkgreen':'red'}}>{walk?'green light':'red light'}</h1>
  </>
}
